#include "requirement_associate_task_table.h"
#include "sqlite_manager.h"
#include "easylogging++.h"

RequirementAssociateTaskTable::RequirementAssociateTaskTable()
{

}

bool RequirementAssociateTaskTable::insertNewAssociate(
        QString uuid,
        QString requirementUuid,
        QString taskUuid)
{
    SqliteManager sm;
    bool ret = sm.insertRowData("requirement_associate_with_task",
    {
        "uuid", "requirement_uuid", "task_uuid"
    },
    {
        uuid, requirementUuid, taskUuid
    });
    if (!ret)
    {
        LOG(ERROR) << "insert row data failed, error info: "
                   << sm.lastError().toStdString();
    }

    return ret;
}

bool RequirementAssociateTaskTable::deleteOneAssociate(QString uuid)
{
    SqliteManager sm;
    bool ret = sm.deleteData("requirement_associate_with_task",
    {{"uuid", uuid}});
    if (!ret) {
        LOG(ERROR) << "delete one associate failed, error info: "
                   << sm.lastError().toStdString();
    }

    return ret;
}
